package hebClustering.searchEngines;

/**
 * A data structure that holds information about a search result.
 *
 */
public class WebsiteInformation {
	
	private String url;
	private String description;
	private String title;
	
	/**
	 * Creates a new WebsiteInformation with a URL.
	 * 
	 * @param url
	 */
	public WebsiteInformation(String url){
		this.url = url;
		int backslashIndex = url.lastIndexOf('\\');
		if (backslashIndex == -1) backslashIndex = url.lastIndexOf('/');
		if (backslashIndex != -1)
			title = url.substring(backslashIndex+1, url.length());
		description = "";
	}
	
	/**
	 *  Creates a new WebsiteInformation with a URL, site title, and sire description.
	 * 
	 * @param url
	 * @param title
	 * @param description
	 */
	public WebsiteInformation(String url, String title, String description) {
		this(url);
		this.description = description;
		this.title = title;
	}

	/**
	 * Get the site's description.
	 * 
	 * @return The site's description.
	 */
	public String getDescription(){
		if (description == null) return null;
		if (description.equals("")) return null;
		if (description.contains("This feature is not available right now")) return null;
		return description;
	}
	

	/**
	 * Get the site's title.
	 * 
	 * @return The site's title.
	 */
	public String getTitle(){
		return title;
	}
	
	/**
	 * Get the site's URL.
	 * 
	 * @return The site's URL.
	 */
	public String getUrl(){
		return url;
	}
	
	/**
	 * Return a string representation of the data structure.
	 * 
	 * @return A string representation.
	 */
	public String toString(){
		return "URL: " + url + "\nTitle: " + title +"\nDescription: " + description + "\n";
	}

	/**
	 * Sets the URL.
	 * 
	 * @param url
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * Sets the description.
	 * 
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Sets the title.
	 * 
	 * @param title
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	
	

}
